<title>在线升级</title>

<script type="text/html" template>
    <link rel="stylesheet" href="{{ layui.setter.base }}style/template.css" media="all">
</script>

<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <a lay-href="">扩展</a>
        <a><cite>云服务</cite></a>
        <a><cite>在线升级</cite></a>
    </div>
</div>

<div class="layui-fluid layadmin-homepage-fluid">
    <div class="layui-row layui-col-space8">

        <div class="layui-col-md9">
            <div class="layui-fluid layadmin-homepage-content">

                <div class="layui-row layui-col-space20 layadmin-homepage-list-imgtxt">
                    <div class="layui-col-md12">
                        <div class="layadmin-homepage-panel layadmin-homepage-shadow">
                            <div id="upload-body" class="layui-card homepage-bottom">
                                <div class="layui-card-header">
                                    <h3 class="panel-title">
                                        <i class="layui-icon layui-icon-website"></i>
                                        在线升级
                                    </h3>
                                </div>
                                <div class="layui-card-body">
                                    <div class="panel-body layadmin-homepage-shadow">

                                        {present name='version'}
                                        <div class="media-body">
                                            <div class="pad-btm">
                                                {$version.title}
                                            </div>
                                            <p>{$version.content}</p>
                                            <div class="media">
                                                <div class="media-right layui-hide">
                                                    <ul class="list-inline">
                                                        <li>
                                                            <i class="layui-icon layui-icon-camera-fill"></i>
                                                            <span>107</span>
                                                        </li>
                                                        <li>
                                                            <i class="layui-icon layui-icon-group"></i>
                                                            <span>95</span>
                                                        </li>
                                                    </ul>
                                                </div>
                                                <div class="media-left layui-hide">
                                                    <ul class="list-inline">
                                                        <li>
                                                            <a href="javascript:;">

                                                                <img class="img-xs"
                                                                     src="/static/admin/style/res/template/portrait.png">
                                                            </a>
                                                        </li>
                                                        <li>
                                                            <a href="javascript:;">

                                                                <img class="img-xs"
                                                                     src="/static/admin/style/res/template/portrait.png">
                                                            </a>
                                                        </li>
                                                        <li>
                                                            <a href="javascript:;">

                                                                <img class="img-xs"
                                                                     src="/static/admin/style/res/template/portrait.png">
                                                            </a>
                                                        </li>
                                                        <li>
                                                            <a href="javascript:;" class="">
                                                                14+
                                                            </a>
                                                        </li>
                                                    </ul>
                                                </div>
                                            </div>
                                            <button onclick="next('admin/Version/download')"   class="layui-btn layui-btn-fluid upload " >在线升级</button>
                                        </div>
                                        {else/}
                                        <div class="media-body">
                                            <div class="pad-btm">
                                               当前版本 v{:config('setting.version')}<sup>build{:config('setting.build')}</sup>
                                            </div>
                                            <button class="layui-btn layui-btn-fluid">暂无新版本</button>
                                        </div>
                                        {/present}
                                    </div>

                                </div>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>

        <div class="layui-col-md3">

            {include file="admin/version/tips"/}
        </div>

    </div>
</div>

<script>
    layui.use(['admin'], function () {
        var $ = layui.$
            , admin = layui.admin
            ,element = layui.element;

        window.next = function (url) {

            $.ajax({
                url:url,
                dataType: "json", //返回格式为json
                type: "GET", //请求方式
                success: function (req) {
                    //请求成功时处理
                    if (0 == req.code) {
                        $("#upload-body").html(req.data.html);

                    } else {
                           layer.msg(req.message);

                    }
                },
                complete: function () {
                    //请求完成的处理
                },
                error: function (err) {
                    //请求出错处理
                    layer.msg(JSON.stringify(err));
                }
            });
        }
        window.getFile = function  (data){
            $.ajax( {
                type : "POST",
                url : "{:url()}",
                data:data,
                //返回数据的格式
                datatype: "json",
                success : function(result) {
                    if( 'message' == result.type){
                        $('#message').append(result.message);
                    }
                    if( 'file' == result.type){
                        $('#file').append('<div><i class="icon-file"></i> '+result.file+'</div>');
                    }
                    if( 1 == result.is_end){
                        $('#compare_btn').removeAttr('disabled','');
                        $('#compare_btn').html(result.button);
                    }
                    if (0 == result.code) {
                        getFile(result);
                    }else{
                        //提醒
                    }
                },
                error : function(g) {
                    //	$(this).alertmsg('error','结算请求异常，请稍后再试！');
                    return;
                }
            });
        }


    });
</script>